package cn.jbt.api.admin.controller;

import cn.jbt.api.admin.entity.*;
import cn.jbt.api.admin.service.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/system/common")
@Slf4j
@AllArgsConstructor
public class SysCommonController {

    private final ISysUserService iSysUserService;
    private final ISysMenuService iSysMenuService;
    private final ISysDeptService iSysDeptService;
    private final ISysPostService iSysPostService;
    private final ISysRoleService iSysRoleService;

    /**
     * <h2>查询用户列表</h2>
     */
    @PostMapping("/users")
    public List<SysUser> getUsers(@RequestBody SysUser sysUser) {
        return iSysUserService.getAll(sysUser);
    }

    /**
     * <h2>查询菜单列表</h2>
     */
    @PostMapping("/menus")
    public List<SysMenu> getMenus(@RequestBody SysMenu sysMenu) {
        return iSysMenuService.getAll(sysMenu);
    }

    /**
     * <h2>查询部门列表</h2>
     */
    @PostMapping("/depts")
    public List<SysDept> getDepts(@RequestBody SysDept sysDept) {
        return iSysDeptService.getAll(sysDept);
    }

    /**
     * <h2>查询岗位列表</h2>
     */
    @PostMapping("/posts")
    public List<SysPost> getPosts(@RequestBody SysPost sysPost) {
        return iSysPostService.getAll(sysPost);
    }

    /**
     * <h2>查询角色列表</h2>
     */
    @PostMapping("/roles")
    public List<SysRole> getRoles(@RequestBody SysRole sysRole) {
        return iSysRoleService.getAll(sysRole);
    }

}
